﻿using System;
using Luna.Data;
using Luna.Data.Budget;
using Rhino.Mocks;

namespace Luna.Services.Test.Budget
{
    public class BudgetDataCreator : DataCreator
    {
        private const string COMMENT = "Comment";
        private const string DESCRIPTION = "Description";

        private const string NAME = "Name";

        public void Configure()
        {
        }

        public IBudgetData CreateBudgetData()
        {
            IBudgetData L_Return = MockRepository.GenerateMock<object, IBudgetData, IEquatable<object>>() as IBudgetData;

            LoadKey(L_Return);

            L_Return.Stub(x => x.Name).PropertyBehavior();
            L_Return.Stub(x => x.Comment).PropertyBehavior();
            L_Return.Stub(x => x.Start).PropertyBehavior();
            L_Return.Stub(x => x.End).PropertyBehavior();
            L_Return.Stub(x => x.MainBudgetID).PropertyBehavior();

            L_Return.Name = GetString(NAME);
            L_Return.Comment = GetString(COMMENT);
            L_Return.Start = GetDate();
            L_Return.End = GetDate();
            L_Return.MainBudgetID = Guid.NewGuid();

            return L_Return;
        }

        public ICategoryData CreateCategoryData()
        {
            ICategoryData L_Return = MockRepository.GenerateMock<object, ICategoryData, IEquatable<object>>() as ICategoryData;

            LoadKey(L_Return);

            L_Return.Stub(x => x.Name).PropertyBehavior();
            L_Return.Stub(x => x.Description).PropertyBehavior();
            L_Return.Stub(x => x.Color).PropertyBehavior();

            L_Return.Name = GetString(NAME);
            L_Return.Description = GetString(DESCRIPTION);
            L_Return.Color = "#FF123456";

            /*;

            L_Return.Stub(x => x.Equals(Arg<object>.Matches(a => CheckTrue(a, L_Return)))).Return(true);
            L_Return.Stub(x => x.Equals(Arg<object>.Matches(a => CheckFalse(a, L_Return)))).Return(false);*/

            return L_Return;
        }

        public void Setup(IDataContext P_Context)
        {
            P_Context.Stub(x => x.Create<ICategoryData>()).WhenCalled(x => x.ReturnValue = CreateCategoryData()).Return(CreateCategoryData());
            P_Context.Stub(x => x.Create<IBudgetData>()).WhenCalled(x => x.ReturnValue = CreateBudgetData()).Return(CreateBudgetData());
        }
    }
}